package day7;

/**
 * @author oldliu
 * @since 1.0
 */
public class Arry42 {
    public static void main(String[] args) {
        //int[] a = {1, 22, 31, 11, 21, -53, 23, 44, 66, 67, 88, 33, 26, 62, 56, 99, 100};
        //int a[] = {29, 22, 21, 12, 4, 3, 0, 1, 2, -3, -4};
        int a[] = {29, 22, 21, 12};
        int[] b = new int[a.length];//长度
        int[] c = new int[a.length];//位置
        int i, tou = 0, k = 1, j = 0;
        for (i = 0; i < a.length - 1; i++) {
            if (a[i] < a[i + 1]) {
                k++;
            } else {
                b[j] = k;
                c[j] = tou;
                j++;
                tou = i + 1;
                k = 1;
            }
            b[j] = k;
            c[j] = tou;
        }
        int t;
        for (i = 0; i < b.length - 1; i++) {
            for (j = 0; j < b.length - 1 - i; j++) {
                if (b[j] < b[j + 1]) {
                    t = b[j];
                    b[j] = b[j + 1];
                    b[j + 1] = t;
                    t = c[j];
                    c[j] = c[j + 1];
                    c[j + 1] = t;
                }
            }
        }
        System.out.print("最长的递增子数组是:");
        System.out.println((c[0] + 1) + "开始");
        for (i = c[0]; i < c[0] + b[0]; i++) {
            System.out.print(a[i] + " ");
        }
    }
}
